package com.ehotting.edsta.diagnosisPredict.controller;

import com.ehotting.eaf.core.domain.R;
import com.ehotting.edsta.diagnosisPredict.domain.dto.FeOperator;
import com.ehotting.edsta.diagnosisPredict.domain.dto.FeProcessingTreeDto;
import com.ehotting.edsta.diagnosisPredict.feign.FeOperatorFeignService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 特征算子
 */
@Api(tags = "FeOperatorController",description = "特征算子接口")
@RestController
@RequestMapping("/feOperator")
public class FeOperatorController {

    @Autowired
    private FeOperatorFeignService operatorFeignService;

    /**
     * 特征算子字段列表
     *
     * @return
     */
    @ApiOperation(value = "特征算子字段列表",notes = "返回的数据类型：List\\<FeOperator\\>")
    @GetMapping(value = "/list")
    public R<List<FeOperator>> list(@RequestParam(name ="canvasld", required = false) Long canvasld,
                                    @RequestParam(name ="coordinate", required = false) String coordinate,
                                    @RequestParam(name ="createTime", required = false) String createTime,
                                    @RequestParam(name ="id", required = false) Long id,
                                    @RequestParam(name ="iteminfold", required = false) Long iteminfold,
                                    @RequestParam(name ="itemname", required = false) String itemname,
                                    @RequestParam(name ="menuId", required = false) Long menuId,
                                    @RequestParam(name ="operatorType", required = false) String operatorType,
                                    @RequestParam(name ="operatorname", required = false) String operatorname,
                                    @RequestParam(name ="pid", required = false) Long pid){
        return R.convert(operatorFeignService.list(canvasld, coordinate, createTime, id,
                iteminfold, itemname, menuId, operatorType, operatorname,pid));
    }

    /**
     * 特征算子字段列表
     *
     * @return
     */
    @ApiOperation(value = "特征算子字段列表",notes = "返回的数据类型：List\\<FeProcessingTreeDto\\>")
    @ApiResponses(value = {
            @ApiResponse(code = 1,message = "",response = FeProcessingTreeDto.class)
    })
    @GetMapping(value = "/getTree")
    public R<List<FeProcessingTreeDto>> getTree(@RequestParam(name = "canvasld",required = false)Long canvasld){
        return R.convert(operatorFeignService.getTree(canvasld));
    }

    /**
     * 新建数据处理算子
     *
     * @return
     */
    @ApiOperation(value = "新建数据处理算子",notes = "返回的数据类型：FeOperator")
    @PostMapping(value = "/save")
    public R<FeOperator> save(@RequestBody FeOperator feOperator){
        return R.convert(operatorFeignService.save(feOperator));
    }

    /**
     * 算子执行
     *
     * @return
     */
    @ApiOperation(value = "算子执行",notes = "返回的数据类型：Map\\<String, String\\>")
    @PostMapping(value = "/exec")
    public R<Map<String, String>> exec(@RequestBody FeOperator feOperator){
        return R.convert(operatorFeignService.exec(feOperator));
    }

    /**
     * 算子打开获取数据结果
     *
     * @return
     */
    @ApiOperation(value = "算子打开获取数据结果",notes = "返回的数据类型：Map\\\\<String, String\\\\>")
    @PostMapping(value = "/getCacheById")
    public R<Map<String, String>> getCacheById(@RequestParam(name = "id",required = false)String id){
        return R.convert(operatorFeignService.getCacheById(id));
    }

}
